package com.msb.baseFunctionalInterface;

import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class ComparableTest {
    public static void main(String[] args) {
        String[] strs = {"abc", "dddd", "s"};
        Arrays.sort(strs, (String str1, String str2) -> str1.length() - str2.length());
        System.out.println(Arrays.toString(strs));
//        Comparator<String> comparator = new Comparator<String>() {
//            @Override
//            public int compare(String str1, String str2) {
//                return str1.length() - str2.length();
//            }
//        };
//        Arrays.sort(strs, comparator);

        List<String> list = Arrays.asList("dfasf", "ddd", "sseedv");
        list.sort((String str1, String str2) -> str1.length() - str2.length());
        System.out.println(list);
    }




}
